package svgedit.gui.actions;

import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

import svgedit.gui.Frame;

/** Shows confirm changes dialog, then exits the application.
 */
@SuppressWarnings("serial")
public class QuitAction extends AbstractAction {

	JFileChooser dialog = new JFileChooser();
    private Frame frame;

    /** Create this action for the given frame */
    public QuitAction(Frame frame) {
        super("Quit");
        this.frame = frame;
    }

    public void actionPerformed(ActionEvent ae) {
    	int option;

    	if(frame.view.getSaveState() !=0){
	        int exit =JOptionPane.showConfirmDialog(frame,"Do you want to save before exit?"
	                        ,"Confrim Exit", JOptionPane.YES_NO_CANCEL_OPTION);
	        if (exit==JOptionPane.YES_OPTION){		
	        	option = dialog.showSaveDialog(frame);
	        	System.exit(0);
	        }else if (exit==JOptionPane.NO_OPTION) {
	        	System.exit(0);
	        }else if(exit==JOptionPane.CANCEL_OPTION){	        	
	        }
    	}
}


        
    }


